#ifndef CURSESCLASS_H
#define CURSESCLASS_H

#include <string>
#include <vector>

class Window;

class Curses {
public:
	enum Color {
		WHITE = 0,
		RED	  = 1,
		GREEN = 2,
		YELLOW = 3,
		BLUE = 4,
		MAGENTA = 5,
		CYAN = 6,
		GRAY = 7,
		DARK_GRAY = 8,
		LIGHT_RED = 9,
		LIGHT_GREEN = 10,
		LIGHT_YELLOW = 11,
		LIGHT_BLUE = 12,
		LIGHT_MAGENTA = 13,
		LIGHT_CYAN = 14,
		WHITE2 = 15,
		BLACK = 16
	};
public:
	static Curses& instance();
	void refresh();
//	void refresh(Window* win);
	
	void print(int x, int y, const std::string& str);
	void print(Window* win, int x, int y, const std::string& str);
	
	void putchar(Window* win, int x, int y, char character);
	
	void shutdown();

	int getchar();

	void clearScreen();

	inline void setCurrentWindow(Window* win);
	inline Window* stdscr() const;
	
	void pushWindow(Window* window);
	void popWindow();
	inline Window* topWindow() const;
	
private:
	Curses();
	void init();
private:
	Window* m_stdscr;
	Window* m_current;
	bool m_hasColor;
	
	std::vector<Window*> m_windowStack;
};

inline void Curses::setCurrentWindow(Window* win) {
	m_current = win;
}

inline Window* Curses::stdscr() const {
	return m_stdscr;
}

inline Window* Curses::topWindow() const {
	return m_windowStack.back();
}

#endif